/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Daniel Cruz
 */
@Entity
@Table(name = "material")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Material.findAll", query = "SELECT m FROM Material m"),
    @NamedQuery(name = "Material.findByMaterialId", query = "SELECT m FROM Material m WHERE m.materialId = :materialId"),
    @NamedQuery(name = "Material.findByTituloMat", query = "SELECT m FROM Material m WHERE m.tituloMat = :tituloMat"),
    @NamedQuery(name = "Material.findByEdicionMat", query = "SELECT m FROM Material m WHERE m.edicionMat = :edicionMat"),
    @NamedQuery(name = "Material.findByIsbnMat", query = "SELECT m FROM Material m WHERE m.isbnMat = :isbnMat"),
    @NamedQuery(name = "Material.findByCodigoDaneMat", query = "SELECT m FROM Material m WHERE m.codigoDaneMat = :codigoDaneMat"),
    @NamedQuery(name = "Material.findByCodigoBarrasMat", query = "SELECT m FROM Material m WHERE m.codigoBarrasMat = :codigoBarrasMat"),
    @NamedQuery(name = "Material.findByFechaMat", query = "SELECT m FROM Material m WHERE m.fechaMat = :fechaMat"),
    @NamedQuery(name = "Material.findByDescripcionMat", query = "SELECT m FROM Material m WHERE m.descripcionMat = :descripcionMat")})
public class Material implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "material_id")
    private Long materialId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "titulo_mat")
    private String tituloMat;
    @Basic(optional = false)
    @NotNull
    @Column(name = "edicion_mat")
    private int edicionMat;
    @Size(max = 2147483647)
    @Column(name = "isbn_mat")
    private String isbnMat;
    @Size(max = 2147483647)
    @Column(name = "codigo_dane_mat")
    private String codigoDaneMat;
    @Size(max = 2147483647)
    @Column(name = "codigo_barras_mat")
    private String codigoBarrasMat;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fecha_mat")
    @Temporal(TemporalType.DATE)
    private Date fechaMat;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "descripcion_mat")
    private String descripcionMat;
    @ManyToMany(mappedBy = "materialCollection")
    private Collection<Autor> autorCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "materialId")
    private Collection<Volumen> volumenCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "materialId")
    private Collection<Libro> libroCollection;
    @JoinColumn(name = "id_editorial", referencedColumnName = "id_editorial")
    @ManyToOne(optional = false)
    private Editorial idEditorial;
    @JoinColumn(name = "bat_id_idioma_mat", referencedColumnName = "bat_id")
    @ManyToOne
    private BBasicaTipo batIdIdiomaMat;
    @JoinColumn(name = "bat_id_sala_mat", referencedColumnName = "bat_id")
    @ManyToOne(optional = false)
    private BBasicaTipo batIdSalaMat;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "materialId")
    private Collection<Audiovisual> audiovisualCollection;

    public Material() {
    }

    public Material(Long materialId) {
        this.materialId = materialId;
    }

    public Material(Long materialId, String tituloMat, int edicionMat, Date fechaMat, String descripcionMat) {
        this.materialId = materialId;
        this.tituloMat = tituloMat;
        this.edicionMat = edicionMat;
        this.fechaMat = fechaMat;
        this.descripcionMat = descripcionMat;
    }

    public Long getMaterialId() {
        return materialId;
    }

    public void setMaterialId(Long materialId) {
        this.materialId = materialId;
    }

    public String getTituloMat() {
        return tituloMat;
    }

    public void setTituloMat(String tituloMat) {
        this.tituloMat = tituloMat;
    }

    public int getEdicionMat() {
        return edicionMat;
    }

    public void setEdicionMat(int edicionMat) {
        this.edicionMat = edicionMat;
    }

    public String getIsbnMat() {
        return isbnMat;
    }

    public void setIsbnMat(String isbnMat) {
        this.isbnMat = isbnMat;
    }

    public String getCodigoDaneMat() {
        return codigoDaneMat;
    }

    public void setCodigoDaneMat(String codigoDaneMat) {
        this.codigoDaneMat = codigoDaneMat;
    }

    public String getCodigoBarrasMat() {
        return codigoBarrasMat;
    }

    public void setCodigoBarrasMat(String codigoBarrasMat) {
        this.codigoBarrasMat = codigoBarrasMat;
    }

    public Date getFechaMat() {
        return fechaMat;
    }

    public void setFechaMat(Date fechaMat) {
        this.fechaMat = fechaMat;
    }

    public String getDescripcionMat() {
        return descripcionMat;
    }

    public void setDescripcionMat(String descripcionMat) {
        this.descripcionMat = descripcionMat;
    }

    @XmlTransient
    public Collection<Autor> getAutorCollection() {
        return autorCollection;
    }

    public void setAutorCollection(Collection<Autor> autorCollection) {
        this.autorCollection = autorCollection;
    }

    @XmlTransient
    public Collection<Volumen> getVolumenCollection() {
        return volumenCollection;
    }

    public void setVolumenCollection(Collection<Volumen> volumenCollection) {
        this.volumenCollection = volumenCollection;
    }

    @XmlTransient
    public Collection<Libro> getLibroCollection() {
        return libroCollection;
    }

    public void setLibroCollection(Collection<Libro> libroCollection) {
        this.libroCollection = libroCollection;
    }

    public Editorial getIdEditorial() {
        return idEditorial;
    }

    public void setIdEditorial(Editorial idEditorial) {
        this.idEditorial = idEditorial;
    }

    public BBasicaTipo getBatIdIdiomaMat() {
        return batIdIdiomaMat;
    }

    public void setBatIdIdiomaMat(BBasicaTipo batIdIdiomaMat) {
        this.batIdIdiomaMat = batIdIdiomaMat;
    }

    public BBasicaTipo getBatIdSalaMat() {
        return batIdSalaMat;
    }

    public void setBatIdSalaMat(BBasicaTipo batIdSalaMat) {
        this.batIdSalaMat = batIdSalaMat;
    }

    @XmlTransient
    public Collection<Audiovisual> getAudiovisualCollection() {
        return audiovisualCollection;
    }

    public void setAudiovisualCollection(Collection<Audiovisual> audiovisualCollection) {
        this.audiovisualCollection = audiovisualCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (materialId != null ? materialId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Material)) {
            return false;
        }
        Material other = (Material) object;
        if ((this.materialId == null && other.materialId != null) || (this.materialId != null && !this.materialId.equals(other.materialId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Material[ materialId=" + materialId + " ]";
    }
    
}
